package ch.ethz.fcl.metrobuzz.render.techniques.colors;

import java.awt.Color;

import org.lwjgl.opengl.GL11;

import ch.ethz.fcl.metrobuzz.data.scene.basemap.Edge.EdgeType;

public class SGMRTColorTable {
	public static final Color GREY_VERY_DARK = new Color(20, 37, 36);
	public static final Color GREY_BLUE_DARK = new Color(66, 82, 91);
	public static final Color GREY_BLUE = new Color(147, 161, 172);
	public static final Color WHITEISH = new Color(235, 234, 255);
	public static final Color RED_BORDEAUX = new Color(146, 20, 12);

	public static final Color TURQUOISE = new Color(0, 140, 120);
	public static final Color GREEN_OLIVE = new Color(120, 142, 21);
	public static final Color YELLOW_MUSTARD = new Color(217, 189, 55);
	public static final Color ORANGE_PEACH = new Color(242, 133, 52);
	public static final Color RED_PINK = new Color(191, 29, 74);

	public static final Color RED_BORDEAUX_2 = new Color(140, 7, 31);
	public static final Color BLUE = new Color(32, 90, 140);
	public static final Color BLUE_LIGHT = new Color(141, 213, 242);
	public static final Color BLUE_LIGHT_GREY = new Color(164, 187, 218);
	public static final Color ORANGE = new Color(242, 135, 5);

	public static final int NS = 200;
	public static final int EW = 201;
	public static final int NE = 202;
	public static final int CC = 203;
	public static final int LRT = 204;
	public static final int BUS = 205;

	public static final Color NS_COLOR = new Color(217, 29, 7);
	public static final Color EW_COLOR = new Color(5, 157, 77);
	public static final Color NE_COLOR = new Color(147, 17, 162);
	public static final Color CC_COLOR = new Color(250, 155, 16);
	public static final Color LRT_COLOR = new Color(115, 133, 122);

	// http://kuler.adobe.com/#themeID/1472341
	public static final Color[] KEY_FOR_NEXT = { GREY_VERY_DARK,
			GREY_BLUE_DARK, GREY_BLUE, WHITEISH, RED_BORDEAUX };

	// http://kuler.adobe.com/#themeID/1460680
	public static final Color[] PULPS = { TURQUOISE, GREEN_OLIVE,
			YELLOW_MUSTARD, ORANGE_PEACH, RED_PINK };

	// http://kuler.adobe.com/#themeID/1497384
	public static final Color[] ATDANCE = { RED_BORDEAUX_2, BLUE, BLUE_LIGHT,
			BLUE_LIGHT_GREY, ORANGE };

	public static void assignColor(int i, float alpha) {
		float r, g, b;
		switch (i) {
		case 0:
			r = (float) RED_PINK.getRed() / 255;
			b = (float) RED_PINK.getBlue() / 255;
			g = (float) RED_PINK.getGreen() / 255;
			break;

		case 1:
			r = (float) GREEN_OLIVE.getRed() / 255;
			g = (float) GREEN_OLIVE.getGreen() / 255;
			b = (float) GREEN_OLIVE.getBlue() / 255;
			break;

		case 2:
			r = (float) BLUE.getRed() / 255;
			g = (float) BLUE.getGreen() / 255;
			b = (float) BLUE.getBlue() / 255;
			break;

		case 3:
			r = (float) GREY_BLUE.getRed() / 255;
			g = (float) GREY_BLUE.getGreen() / 255;
			b = (float) GREY_BLUE.getBlue() / 255;
			break;

		case 4:
			r = (float) RED_BORDEAUX.getRed() / 255;
			g = (float) RED_BORDEAUX.getGreen() / 255;
			b = (float) RED_BORDEAUX.getBlue() / 255;
			break;

		case 5:
			r = (float) YELLOW_MUSTARD.getRed() / 255;
			g = (float) YELLOW_MUSTARD.getGreen() / 255;
			b = (float) YELLOW_MUSTARD.getBlue() / 255;
			break;

		case 6:
			r = (float) ORANGE_PEACH.getRed() / 255;
			g = (float) ORANGE_PEACH.getGreen() / 255;
			b = (float) ORANGE_PEACH.getBlue() / 255;
			break;

		default:
			r = (float) ORANGE.getRed() / 255;
			g = (float) ORANGE.getGreen() / 255;
			b = (float) ORANGE.getBlue() / 255;
			break;
		}

		GL11.glColor4f(r, g, b, alpha);
	}

	public static void assignSubwayColor(byte type, float alpha) {
		if (type == EdgeType.EW)
			assignSubwayColor(EW, alpha);
		else if (type == EdgeType.NS)
			assignSubwayColor(NS, alpha);
		else if (type == EdgeType.NE)
			assignSubwayColor(NE, alpha);
		else if (type == EdgeType.CC)
			assignSubwayColor(CC, alpha);
		else if (type == EdgeType.LRT)
			assignSubwayColor(LRT, alpha);
		else
			assignSubwayColor(BUS, alpha);
	}

	public static void assignSubwayColor(int index, float alpha) {
		switch (index) {
		case EW:
			GL11.glColor4f(5.0f / 255, 157.0f / 255, 77.0f / 255, alpha);
			break;
		case NS:
			GL11.glColor4f(217.0f / 255, 29.0f / 255, 7.0f / 255, alpha);
			break;
		case NE:
			GL11.glColor4f(147.0f / 255, 17.0f / 255, 162.0f / 255, alpha);
			break;
		case CC:
			GL11.glColor4f(250.0f / 255, 155.0f / 255, 16.0f / 255, alpha);
			break;
		case LRT:
			GL11.glColor4f(115.0f / 255, 133.0f / 255, 122.0f / 255, alpha);
			break;
		case BUS:
			GL11.glColor4f(92.0f / 255, 3f / 255, 102.0f / 255, alpha);
			break;
		}
	}
}
